/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#pragma once

#include <baja/common.hpp>
#include <baja/graphics.hpp>
#include <baja/graphics/scenes.hpp>
#include <baja/app/input.hpp>
#include <baja/app/debug_console.hpp>
#include <journal/views/interfaces.h>
#include <journal/app/constants.h>
#include <journal/views/scene_state.h>

namespace journal { namespace view {

namespace b = baja;
namespace a = baja::app;
namespace g = baja::graphics;
namespace gs = baja::graphics::scenes;
namespace gd = baja::graphics::dx11_1::details;

class input_references : 
    public iinput_references, 
    public std::enable_shared_from_this<input_references>
{
public:
    input_references();

    static std::shared_ptr<input_references> create()
    {
        std::shared_ptr<input_references> returnValue = std::make_shared<input_references>();
        return returnValue->shared_from_this();
    }

    // irender_observer
    void onRender();
    void onScreenChange(const a::screen_change_args& args) { /* noop */ };
    void onResize(const a::resize_args& args) { /* noop */}
    void onVisibilityChanged(const bool visible) { /* noop */ }

    // iinput_observer
    void onGesture(const a::gesture_args& args, void* context) { /*noop*/}
    void onPointer(const a::pointer_args& args, void* context = nullptr);
    void onKey(const a::key_args& args, void* context);

private:
    void renderTouchPoints();

private:
    std::map<b::uint32, a::pointer_args> _activeTouchPoints;
    int32 _lastKey;
    b::stopwatch _keyTimer;
    std::shared_ptr<g::itexture> _touchTexture;
    std::shared_ptr<g::ifont> _font;
};

}} // namespace journal::view